package com.kun.demo03;

import org.junit.Test;

//测试优先级
public class TestPriority {

    class MyThread implements Runnable {

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName() + " is running,priority is "+ Thread.currentThread().getPriority());
        }

    }

    @Test
    public void test() {
        System.out.println(Thread.currentThread().getName() + " is running,priority is "+ Thread.currentThread().getPriority());
        Thread t1 = new Thread(new MyThread(), "myThread1");
        Thread t2 = new Thread(new MyThread(), "myThread2");
        Thread t3 = new Thread(new MyThread(), "myThread3");
        Thread t4 = new Thread(new MyThread(), "myThread4");
        Thread t5 = new Thread(new MyThread(), "myThread5");
        Thread t6 = new Thread(new MyThread(), "myThread6");
        t1.setPriority(Thread.MAX_PRIORITY);
        t1.start();

        t2.setPriority(2);
        t2.start();

        t3.setPriority(3);
        t3.start();

        t4.setPriority(Thread.NORM_PRIORITY);
        t4.start();

        t5.setPriority(6);
        t5.start();

        t6.setPriority(Thread.MIN_PRIORITY);
        t6.start();


    }


}



